﻿using Dubbo.Config.Api;
using Dubbo.Config.Spring;
using Spring.Objects.Factory.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dubbo.Config.Spring.Schema
{
    [
        NamespaceParser(
            Namespace = "http://code.alibabatech.com/schema/dubbo",
            SchemaLocationAssemblyHint = typeof(DubboNamespaceHandler),
            SchemaLocation = "/Dubbo.Config.Spring.Schema/dubbo.xsd"
        )
    ]
    public class DubboNamespaceHandler : NamespaceParserSupport
    {
        public override void Init()
        {
            RegisterObjectDefinitionParser("application", new DubboObjectDefinitionParser(typeof(ApplicationConfig), true));
            //RegisterObjectDefinitionParser("module", new DubboObjectDefinitionParser(ModuleConfig.class, true));
            //RegisterObjectDefinitionParser("registry", new DubboObjectDefinitionParser(RegistryConfig.class, true));
            //RegisterObjectDefinitionParser("monitor", new DubboObjectDefinitionParser(MonitorConfig.class, true));
            //RegisterObjectDefinitionParser("provider", new DubboObjectDefinitionParser(ProviderConfig.class, true));
            //RegisterObjectDefinitionParser("consumer", new DubboObjectDefinitionParser(ConsumerConfig.class, true));
            RegisterObjectDefinitionParser("protocol", new DubboObjectDefinitionParser(typeof(ProtocolConfig), true));
            RegisterObjectDefinitionParser("service", new DubboObjectDefinitionParser(typeof(ServiceObject<>), true));
            RegisterObjectDefinitionParser("reference", new DubboObjectDefinitionParser(typeof(ReferenceObject<>), false));
            //RegisterObjectDefinitionParser("annotation", new DubboObjectDefinitionParser(AnnotationBean.class, true));
        }
    }
}
